<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="LOGGING_IN" scope="page" />

<atleap:content identifier="information" ignore="true" />
<table cellpadding="0" cellspacing="0" border="0" class="tableView" id="userTable">
    <tr>
        <th align="left" width="50%"><atleap:message key="core.user.form.name" /></th>
        <td id="name"><c:out value="${requestScope.user.name}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.user.form.firstName" /></th>
        <td id="firstName"><c:out value="${requestScope.user.firstName}" escapeXml="true" /></td>
    </tr>
    <tr>                                
        <th align="left" width="50%"><atleap:message key="core.user.form.lastName" /></th>
        <td id="lastName"><c:out value="${requestScope.user.lastName}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.user.form.email" /></th>
        <td id="email"><c:out value="${requestScope.user.email}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.user.form.address" /></th>
        <td id="address"><c:out value="${requestScope.user.address}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.user.form.city" /></th>
        <td id="city"><c:out value="${requestScope.user.city}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.user.form.province" /></th>
        <td id="province"><c:out value="${requestScope.user.province}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.user.form.country" /></th>
        <td id="country"><c:out value="${requestScope.user.country}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.user.form.postalCode" /></th>
        <td id="postalCode"><c:out value="${requestScope.user.postalCode}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.user.form.phoneNumber" /></th>
        <td id="phoneNumber"><c:out value="${requestScope.user.phoneNumber}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.user.form.website" /></th>
        <td id="website"><c:out value="${requestScope.user.website}" escapeXml="true" /></td>
    </tr>
    <atleap:isUserInRole roles="core-user-view">
		<tr>
			<th align="left" width="50%"><atleap:message key="core.user.form.freeRoles" /></th>
			<td id="freeRoles"><c:out value="${requestScope.user.freeRolesAsString}" escapeXml="true" /></td>
		</tr>
		<tr>
			<th align="left" width="50%"><atleap:message key="core.user.form.groups" /></th>
			<td id="groups"><c:out value="${requestScope.user.groupsAsString}" escapeXml="true" /></td>
		</tr>
    </atleap:isUserInRole>
</table>
<atleap:isUserInRole roles="core-user-view">
    <h3><atleap:message key="core.user.form.roles" /></h3>
    <table cellpadding="0" cellspacing="0" border="0" class="rolesDetails">
        <tr>
            <th><atleap:message key="core.role.form.name" /></th>
            <th><atleap:message key="core.role.form.title" /></th>
            <th><atleap:message key="core.role.form.description" /></th>
        </tr>
        <atleap:iterator items="${requestScope.user.groups}" var="group">
            <tr>
                <td colspan="3" class="mainHeader"><c:out value="${group.title}" escapeXml="true" /></td>
            </tr>
            <atleap:iterator items="${group.roles}" var="role">
                <tr>
                    <td><c:out value="${role.name}" escapeXml="true" /></td>
                    <td><c:out value="${role.title}" escapeXml="true" /></td>
                    <td><c:out value="${role.description}" escapeXml="true" /></td>
                </tr>
            </atleap:iterator>
        </atleap:iterator>
    </table>
</atleap:isUserInRole>
<atleap:form action="core/user/callUpdate" method="GET" validateOnSubmit="false">
    <html:hidden property="${pageScope.LOGGING_IN}" value="true" />
    <html:hidden property="name" value="${requestScope.user.name}" />
    <atleap:isUserInRole roles="core-user-update" var="canUpdate" />
    <atleap:isUserInRole roles="core-user-updateOneself" var="canUpdateOneself" />
    <c:if test="${canUpdate || (canUpdateOneself && viewingOneself)}">
        <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.callUpdate" /></atleap:submit>
    </c:if>
    <atleap:cancel styleClass="button">
        <atleap:isUserInRole roles="core-user-list" var="canList" />
        <c:choose>
			<c:when test="${canList}">
				<atleap:message key="core.commons.buttons.showList" />
			</c:when>
			<c:otherwise>
				<atleap:message key="core.commons.buttons.cancel" />
			</c:otherwise>
		</c:choose>
	</atleap:cancel>
</atleap:form>
